#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char const* argv[])
{
    int n, i, sum;
    char buf[16];

    printf("PERFECTION OUTPUT\n");
    while (EOF != scanf("%d", &n)) {
        if (n == 0) break;

        sum = 0;
        for (i = 2; i <= n / 2 + 1; i++) {
            if (n % i == 0) {
                sum += i;
            }
        }
        /* 1 isn't the proper divisor. So 1 isn't the perfect number*/
        if (n != 1) sum += 1; 
        
        if (sum < n) {
            strcpy(buf, "DEFICIENT");
        } else if (sum == n) {
            strcpy(buf, "PERFECT"); 
        } else {
            strcpy(buf, "ABUNDANT");
        }

        printf("%5d  %s\n", n, buf);
    }
    printf("END OF OUTPUT\n");

    return 0;
}
